package vn.edu.saigontech.ncms.service.impl;

import java.sql.Time;
import java.util.Collection;

import org.hibernate.Criteria;
import org.hibernate.criterion.Order;

import vn.edu.saigontech.ncms.model.system.Shift;
import vn.edu.saigontech.ncms.service.ShiftService;

public class ShiftServiceImpl extends HibernateGenericService<Shift, Long> implements ShiftService {
	
	public Shift add(Time startTime, Time endTime) {
		Shift shift = new Shift();
		shift.setStartTime(startTime);
		shift.setEndTime(endTime);
		return super.persist(shift);
	}
	
	@Override
	@SuppressWarnings("unchecked")
	public Collection<Shift> findAll() {
		Criteria criteria = this.createCriteria();
		criteria.addOrder(Order.asc("startTime"));
		return criteria.list();
	}
}